package org.ubc.cs410.disposal2020.client.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.gwt.maps.client.geom.LatLng;

/*
 * client data object, equivalence of BuildingBoudary.Class
 * To be stored on client side
 */

public class BuildingBoundaryDto implements Serializable {
	private static final long serialVersionUID = 1L;

	private Long id;

	private Integer buildingId;
	private List<Float> latitudes;
	private List<Float> longitudes;

	public BuildingBoundaryDto() {
		// Empty constructor for stupid GWT serialization
	}

	public BuildingBoundaryDto(Integer buildingId, List<Float> latitudes,
			List<Float> longitudes) {
		super();
		this.buildingId = buildingId;
		this.latitudes = latitudes;
		this.longitudes = longitudes;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<Float> getLatitudes() {
		return latitudes;
	}

	public void setLatitudes(List<Float> latitudes) {
		this.latitudes = latitudes;
	}

	public List<Float> getLongitudes() {
		return longitudes;
	}

	public void setLongitudes(List<Float> longitudes) {
		this.longitudes = longitudes;
	}

	public Integer getBuildingId() {
		return buildingId;
	}

	public void setBuildingId(Integer buildingId) {
		this.buildingId = buildingId;
	}
	
	public LatLng findCentre(ArrayList<LatLng> bounds){
        float latsum = 0;
        float longsum = 0;
	    int size = bounds.size();
	    for(int i = 0; i < size; i++) {
            latsum += bounds.get(i).getLatitude();
            longsum += bounds.get(i).getLongitude();
	    }
	    latsum = latsum / size;
	    longsum = longsum / size;
	    return LatLng.newInstance(latsum, longsum);
	}

}
